home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / H001C.ZIP / DJGPP3.ZIP / DRIVERS / ATI.ASM < prev    next >
Assembly Source File  |  1991-03-15  |  5KB  |  212 lines

  1. ; This is file ATIVGA.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14. ;
  15. ; Modify for the ATI VGA WONDER 
  16. ; by Luc Bussieres, bussiere@dmi.usherb.ca
  17. ; University of Sherbrooke
  18. ; March 9th, 1991
  19. ;
  20.  
  21. cseg    segment    byte public 'code'
  22.     assume    cs:cseg, ds:cseg, es:cseg, ss:nothing
  23.  
  24.     dw    offset init_routine
  25.     dw    offset paging_routine
  26.         dw      0       ; set to 1 if separate read & write windows or
  27.             ; only 64K of video RAM (ie: no paging)
  28.  
  29. def_tw    dw    80    ; filled in by go32 if GO32 env. var. is set
  30. def_th    dw    25
  31. def_gw  dw      640
  32. def_gh  dw      480
  33.  
  34. ;--------------------------------------------------------------------------
  35. ; Entry: AX=mode selection
  36. ;        0=80x25 text
  37. ;        1=default text
  38. ;        2=text CX cols by DX rows
  39. ;        3=biggest text
  40. ;        4=320x200 graphics
  41. ;        5=default graphics
  42. ;        6=graphics CX width by DX height
  43. ;        7=biggest non-interlaced graphics
  44. ;        8=biggest graphics
  45. ;
  46. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  47. ;
  48. ; Exit:  CX=width (in pixels or characters)
  49. ;        DX=height
  50.  
  51. init_table    label    word
  52.     dw    offset init_0
  53.     dw    offset init_1
  54.     dw    offset init_2
  55.     dw    offset init_3
  56.     dw    offset init_4
  57.     dw    offset init_5
  58.     dw    offset init_6
  59.     dw    offset init_7
  60.     dw    offset init_8
  61.  
  62. init_routine    proc    far
  63.     cmp    ax,8
  64.     jbe    valid_req
  65.     ret
  66. valid_req:
  67.     shl    ax,1
  68.     mov    bx,ax
  69.     jmp    init_table[bx]
  70.  
  71. init_0: ; 80x25 text
  72.     mov    ax,3
  73.     int    10h
  74.     mov    cx,80
  75.     mov    dx,25
  76.     ret
  77.  
  78. init_1: ; default text
  79.     mov    cx,def_tw
  80.     mov    dx,def_th
  81.     jmp    init_2
  82.  
  83. init_2_table    label    word
  84.     dw    01h, 40, 25
  85.     dw    03h, 80, 25
  86.         dw      23h, 132, 25
  87.         dw      33h, 132, 44
  88. init_2_tend    label    word
  89.  
  90. init_2: ; CX*DX text
  91.     mov    si,offset init_2_table
  92. init_2a:
  93.     cmp    [si+2],cx
  94.     jb    init_2b
  95.     cmp    [si+4],dx
  96.     jb    init_2b
  97.     ; got a big enough one!
  98.     jmp    init_2c
  99. init_2b:
  100.     cmp    si,offset init_2_tend - 6
  101.     je    init_2c
  102.     add    si,6
  103.     jmp    init_2a
  104. init_2c:
  105.     mov    ax,[si]
  106.     push    si
  107.     int    10h
  108.     pop    si
  109.     mov    cx,[si+2]
  110.     mov    dx,[si+4]
  111.     ret
  112.  
  113. init_3: ; biggest text
  114.     mov    ax,[init_2_tend-6]
  115.     int    10h
  116.     mov    cx,[init_2_tend-4]
  117.     mov    dx,[init_2_tend-2]
  118.     ret
  119.  
  120. init_4: ; 320x200 graphics
  121.     mov    ax,13h
  122.     int    10h
  123.     mov    cx,320
  124.     mov    dx,200
  125.     ret
  126.  
  127. init_5: ; default graphics - should be 640x480 if supported
  128.     mov    cx,def_gw
  129.     mov    dx,def_gh
  130.     jmp    init_6
  131.  
  132. init_6_table    label    word
  133.     dw    13h, 320, 200
  134.         dw      61h, 640, 400
  135.         dw      62h, 640, 480
  136.         dw      63h, 800, 600
  137. init_6_tend    label    word
  138.  
  139. init_6: ; CX*DX graphics
  140.     mov    si,offset init_6_table
  141. init_6a:
  142.     cmp    [si+2],cx
  143.     jb    init_6b
  144.     cmp    [si+4],dx
  145.     jb    init_6b
  146.     ; got a big enough one!
  147.     jmp    init_6c
  148. init_6b:
  149.     cmp    si,offset init_6_tend - 6
  150.     je    init_6c
  151.     add    si,6
  152.     jmp    init_6a
  153. init_6c:
  154.     mov    ax,[si]
  155.     push    si
  156.     int    10h
  157.     pop    si
  158.     mov    cx,[si+2]
  159.     mov    dx,[si+4]
  160.     ret
  161.  
  162. init_7: ; biggest non-interlaced graphics
  163.         mov     ax,63h
  164.     int    10h
  165.         mov     cx,800
  166.         mov     dx,600
  167.     ret
  168.  
  169. init_8: ; biggest graphics
  170.         mov     ax,63h
  171.     int    10h
  172.         mov     cx,800
  173.         mov     dx,600
  174.     ret
  175.  
  176. init_routine    endp
  177.  
  178. ;--------------------------------------------------------------------------
  179. ; Entry: AH=read page
  180. ;        AL=write page
  181. ;
  182. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  183. ; This code must be relocatable and may not reference any data!
  184. ;
  185. ; Exit: VGA configured.
  186. ;       AX,BX,CX,DX,SI,DI may be trashed
  187.  
  188.     assume    ds:nothing, es:nothing
  189.  
  190. paging_routine    proc    far
  191.         and     al,07h
  192.         mov     ch,al          ; ch is page number
  193.         mov     dx,01ceh       ; ati register
  194.         mov     al,0b2h        ; plane select
  195.         out     dx,al
  196.         inc     dl
  197.         in      al,dx
  198.         mov     ah,al
  199.         and     ah,0e1h        ; plane mask
  200.         shl     ch,1
  201.         or      ah,ch
  202.         mov     al,0b2h        ; plane select
  203.         dec     dl
  204.         out     dx,ax
  205.     ret
  206. paging_routine    endp
  207.  
  208. ;--------------------------------------------------------------------------
  209.  
  210. cseg    ends
  211.     end
  212.